Don Rene, afamado influencer y próximo emprendedor de IA, decide que será una buena idea darle un giro a su vida y dedicarse al rubro del asesoramiento de inversionistas en la industria de los videojuegos.
El futuro empresario plantea que el éxito relativo de una inversión en una desarrolladora de juegos debe ser analizado desde un punto de vista basado en evidencia y no en la intuición. Por dicha razón, plantea que para el sería ideal que existiera una máquina que, dada las características de un nuevo videojuego (su género, el estudio que lo desarrolla, su historia, etc...), indique si este será potencialmente una inversión rentable o no.
Rene está convencido que el éxito de una inversión en videojuegos estar relacionada por dos características muy relevantes de estos una vez que salen al mercado:
1. La potencial evaluación (Positivo, Negativo, etc...) que le den los usuarios que jugarán el juego.
2. Las potenciales ventas del juego.
Si bien la idea puede sonar excelente, Don Rene carece en su totalidad de una formación en Ciencia de los Datos, por lo que decide ir en ayuda de expertos para implementar su idea.
Sin embargo, como fiel discipulo del libre mercado, decide no contratar a un equipo en particular, si no que tener la libertad de elegir entre muchos equipos que compiten entre si para saber cuál contratar. Para esto recurre a una triquiñuela recurrentemente utilizada en data science: Establecer una competencia abierta y contratar a los que cumplan mejor sus requisitos.
Para esto, Don Rene abre una competencia en la plataforma Codalab (plataforma similar a Kaggle) la cuál, espera que se replete de buenas propuestas. Los equipos que mejor evaluaciones obtengan (los primeros 5 de cada tabla) serán contratados y retribuidos con un cupón canjeable con la friolera cantidad de 1 punto bonus para el proyecto en el curso MDS7202.
El objetivo de este proyecto es relativamente sencillo, pero en extremo ambicioso: Tendrán que aplicar todo lo aprendido hasta este momento con el fin de solucionar 2 problemas distintos:
('Negative', 'Mixed', 'Mostly Positive', 'Positive', 'Very Positive'). La métrica de evaluación utilizada para medir la clasificación es f1_weighted.r_2.Para esto, ustedes contarán un dataset que cuenta con diversa información de los juegos de la plataforma Steam (tales como fecha de lanzamiento, logros disponibles, plataforma, desarrollador, distribuidor, tags, etc...) más las etiquetas y valores a predecir.
El objetivo final es que participen en la competencia generada en Codalab. Una competencia de Data Science funciona generalmente de la siguiente manera:
Por este motivo, se les provee de dos datasets: train.pickle y test.pickle.
Por una parte, train.pickle está preparado que lo utilizen como conjunto de entrenamiento del modelo; por lo que incluye las etiquetas y valores por predecir.
Por otra parte, la evaluación de la competencia será hecha usando test.pickle. Es decir, este dataset solo contiene características de los juegos y ustedes deberán predecir tanto las potenciales evaluaciones como las posibles ventas de estos y subir sus resultados.
Además, tendrán sample subissions, es decir, un ejemplo de como subir las evaluaciones.
Obviamente para subir archivos a la competencia deberán registrarse en Codalab. Puden participar máximo 5 veces en la competencia (la idea es evitar que se sobreajusten a los datos que deben predecir)
IMPORTANTE: Para la clasificación no usen la cantidad de ventas (target de la regresión) como atributo. Por otro lado, para la regresión no utilicen las evaluaciones como atributo para predecir. Infringir estas reglas implicará en no contar el puntaje de la competencia como tampoco poder participar de los bonus por los tops.
Diego Reyes Troncoso
Nombre de usuarios en Codalab: FelipeArias
Nombre del Equipo en Codalab: FelipeArias
El objetivo de este proyecto consiste en aplicar la materia del curso en un desafío de regresión y clasificación.
Los datos que proveen es un dataset con 17881 juegos y sus atributos respectivos, como por ejemplo, los generos y las categorías. Son 16 atributos y la variables objetivos son de tipo categórica y numérica, en este caso, la reseña y el valor del juego.
La primera tarea, la de regresión, se evalua en base al accuracy y la varianza explicada, ya que esta permite medir, que tan exacta es la predicción. La segunda, se evalúa, en función de las métricas f-1 score, precission y recall.
Nuestra propuesta para resolver el problema utilizó una transformación de las columnas, escalándolas y generando n-gramas utilizados para el entrenamiento.
Nuestro modelo cumplió las expectativas para la regresión, pero fracasó rotundamente para la clasificación. Existen diversos motivos para este comportamiento como, por ejemplo, el uso de muchas variables.
import pandas as pd
import numpy as np
import pandas_profiling
import umap
from sklearn.pipeline import Pipeline
from sklearn.model_selection import train_test_split
# Pre-procesamiento
from sklearn.feature_selection import SelectPercentile, f_classif
from sklearn.compose import ColumnTransformer
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MinMaxScaler, OneHotEncoder, StandardScaler
from sklearn import linear_model
from sklearn import svm
from sklearn.decomposition import PCA
from sklearn.decomposition import TruncatedSVD
# Clasifación
from sklearn.svm import SVC
from sklearn.naive_bayes import MultinomialNB
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
# Metricas de evaluación
from sklearn.metrics import classification_report
from sklearn.metrics import accuracy_score
from sklearn.metrics import f1_score
from sklearn.metrics import cohen_kappa_score
import plotly.express as px
from nltk.util import ngrams
from collections import Counter
from wordcloud import WordCloud
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
from nltk import word_tokenize
from spacy.lang.en.stop_words import STOP_WORDS
import spacy
import re
from nltk import bigrams
from nltk import trigrams
import en_core_web_lg
from scipy.stats import zscore
from operator import itemgetter
import collections
stop_words = set(stopwords.words('english')).union(set(STOP_WORDS))
df_train = pd.read_pickle("train.pickle")
profile_df_train = pandas_profiling.ProfileReport(df_train)
profile_df_train.to_file(output_file="profile_df_train.html")
A continuación observamos los juegos que tienen la misma descripición entre sí. Para observar si es que corresponde al mismo juego y a una diferente versión. La idea es quitar datos duplicados.
df_train
| name | release_date | english | developer | publisher | platforms | required_age | categories | genres | tags | achievements | average_playtime | price | short_description | estimated_sells | rating | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | An Aspie Life | 2018-03-29 | 1 | Bradley Hennessey;Joe Watson | EnderLost Studios | windows | 0 | Single-player;Steam Achievements | Adventure;Casual;Free to Play;Indie;Simulation | Free to Play;Adventure;Indie | 23 | 0 | 0.00 | One day your roommate Leaves for no reason. Yo... | 3914 | Mixed |
| 1 | GhostControl Inc. | 2014-06-06 | 1 | bumblebee | Application Systems Heidelberg | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;Simulation;Strategy | Turn-Based;Indie;Simulation | 53 | 65 | 10.99 | Manage a team of ghosthunters and free London ... | 10728 | Mixed |
| 2 | Deponia | 2012-08-06 | 1 | Daedalic Entertainment | Daedalic Entertainment | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Indie | Adventure;Point & Click;Comedy | 19 | 217 | 6.99 | In Deponia, the world has degenerated into a v... | 635792 | Positive |
| 3 | Atlas Reactor | 2016-10-04 | 1 | Trion Worlds | Trion Worlds | windows | 0 | Multi-player;Online Multi-Player;Steam Achieve... | Free to Play;Strategy | Free to Play;Multiplayer;Strategy | 121 | 1240 | 0.00 | SEASON 6 NOW LIVE! The battle for Atlas contin... | 253864 | Positive |
| 4 | CHUCHEL | 2018-03-07 | 1 | Amanita Design | Amanita Design | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Casual;Indie | Adventure;Indie;Casual | 7 | 245 | 7.99 | CHUCHEL is a comedy adventure game from the cr... | 49818 | Mostly Positive |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 7876 | KOEWOTAYORINI / 声之寄托 | 2018-03-26 | 0 | あみそ組 | Pujia8 Studio;Gamera Game | windows | 0 | Single-player;Steam Achievements;Steam Cloud | Adventure;Free to Play;Indie;RPG | Free to Play;Adventure;Anime | 20 | 65 | 0.00 | “喂喂,求求你啦!救救我!” ——你接到这样一个电话 发出这样的求救,给你打电话的人,是一名... | 24130 | Positive |
| 7877 | Montaro | 2016-07-25 | 1 | JCKSLAP | MBDL | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Memes;Cute;Casual | 15 | 174 | 0.79 | Montaro is a DOGE. | 550368 | Very Positive |
| 7878 | Moe Jigsaw | 2018-03-23 | 1 | ARES Inc. | ARES Inc. | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Nudity;Indie | 72 | 0 | 2.89 | "Moe Jigsaw" is the definitive versi... | 10906 | Mostly Positive |
| 7879 | Drunkn Bar Fight | 2016-11-28 | 1 | The Munky | The Munky | windows | 0 | Single-player;Multi-player;Online Multi-Player... | Action;Indie;Early Access | Early Access;Action;Indie | 0 | 0 | 10.99 | VR PARTY GAMEDrunkn Bar Fight is a simple, imm... | 18876 | Mostly Positive |
| 7880 | Intake | 2013-11-06 | 1 | Cipher Prime Studios | Cipher Prime Studios | windows;mac | 0 | Single-player;Steam Achievements;Steam Cloud;S... | Action;Indie | Indie;Action;Great Soundtrack | 77 | 75 | 6.99 | Intake is the new retro-futuristic drugstep ar... | 29625 | Very Positive |
7881 rows × 16 columns
duplicados=df_train[df_train.duplicated(['short_description'])]
duplicados
| name | release_date | english | developer | publisher | platforms | required_age | categories | genres | tags | achievements | average_playtime | price | short_description | estimated_sells | rating | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2207 | Zup! Zero 2 | 2018-09-11 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements | Casual;Indie | Indie;Casual;Puzzle | 160 | 0 | 0.79 | Minimal physical puzzle with explosions | 10184 | Very Positive |
| 2276 | Zup! Zero | 2017-04-06 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 1043 | 187 | 0.79 | Minimal physical puzzle with explosions | 58996 | Very Positive |
| 2350 | Zup! 7 | 2017-12-12 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 2880 | 110 | 0.79 | Minimal physical puzzle with explosions | 38270 | Very Positive |
| 2951 | Hentai Girl Karen | 2019-04-12 | 1 | GirlGame | GirlGame | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;RPG;Simulation | Nudity;Sexual Content;Casual | 100 | 9 | 0.79 | Relax class puzzle game to keep you in a good ... | 19476 | Very Positive |
| 3366 | Dead Effect 2 VR | 2017-10-03 | 1 | BadFly Interactive, a.s. | App Holdings | windows | 0 | Single-player;Multi-player;Co-op;Steam Achieve... | Action;Indie;RPG | Action;RPG;Indie | 166 | 178 | 19.49 | Dead Effect 2 is the newest addition to the ac... | 34271 | Positive |
| 3788 | Hentai Girl Linda | 2018-12-07 | 1 | GirlGame | GirlGame | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;RPG;Simulation | Sexual Content;Nudity;Anime | 100 | 31 | 0.79 | Relax class puzzle game to keep you in a good ... | 59508 | Very Positive |
| 4028 | Zup! 4 | 2017-02-20 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 555 | 338 | 0.79 | Minimal physical puzzle with explosions | 86989 | Positive |
| 4117 | Hentai Girl Betty | 2018-11-06 | 1 | GirlGame | GirlGame | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;RPG;Simulation | Sexual Content;Nudity;Anime | 100 | 13 | 0.79 | Relax class puzzle game to keep you in a good ... | 69882 | Very Positive |
| 4216 | Oik 3 | 2017-11-09 | 1 | Crew Lab | Crew Lab | windows | 0 | Single-player;Steam Achievements | Casual;Indie | Indie;Casual;Puzzle | 604 | 78 | 0.79 | Casual physics puzzle. | 10062 | Positive |
| 4476 | Higurashi When They Cry Hou - Ch.1 Onikakushi | 2015-05-15 | 1 | 07th Expansion | MangaGamer | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure | Visual Novel;Mystery;Anime | 14 | 279 | 4.79 | Higurashi When They Cry is a sound novel. The ... | 88846 | Very Positive |
| 4558 | Zup! 2 | 2016-12-05 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Indie;Casual;Puzzle | 229 | 237 | 0.79 | Minimal physical puzzle with explosions | 248248 | Very Positive |
| 4580 | Higurashi When They Cry Hou - Ch.2 Watanagashi | 2015-11-13 | 1 | 07th Expansion | MangaGamer | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure | Visual Novel;Horror;Anime | 15 | 390 | 5.59 | Higurashi When They Cry is a sound novel. The ... | 20336 | Very Positive |
| 4642 | Higurashi When They Cry Hou - Ch.4 Himatsubushi | 2016-10-13 | 1 | 07th Expansion | MangaGamer | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Casual;Indie | Adventure;Indie;Casual | 8 | 252 | 4.79 | Higurashi When They Cry is a sound novel. The ... | 6552 | Very Positive |
| 4782 | Front Office Football Eight | 2016-11-23 | 1 | Solecismic Software | Solecismic Software | windows | 0 | Single-player;Multi-player;Steam Achievements | Sports | Sports;Simulation;Football | 78 | 0 | 22.99 | Put yourself in the Front Office with Front Of... | 7592 | Mostly Positive |
| 4834 | Zup! 5 | 2017-06-13 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 2130 | 170 | 0.79 | Minimal physical puzzle with explosions | 70434 | Very Positive |
| 5279 | Zup! S | 2018-11-15 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 100 | 0 | 0.79 | Minimal physical puzzle with explosions | 21660 | Very Positive |
| 5343 | Fog of War | 2018-06-18 | 1 | Monkeys Lab. | Neokosmos Technologies Ltd. | windows | 0 | Multi-player;Online Multi-Player;Steam Trading... | Violent;Gore;Action;Indie;Massively Multiplaye... | FPS;World War II;Action | 0 | 138 | 3.99 | Tactical Multiplayer FPS shooter with a story ... | 27588 | Negative |
| 5568 | Spooky's Jump Scare Mansion: HD Renovation | 2017-03-01 | 1 | Albino Moose Games | Albino Moose Games | windows;mac | 0 | Single-player;Steam Achievements;Full controll... | Action;Adventure;Indie | Indie;Horror;Adventure | 26 | 223 | 6.99 | Can you survive 1000 rooms of cute terror? Or ... | 15953 | Positive |
| 5574 | Puzzle Pirates | 2011-08-31 | 1 | Grey Havens, LLC | Grey Havens, LLC | windows;mac | 0 | Single-player;Multi-player;MMO;Co-op;Steam Ach... | Adventure;Casual;Free to Play;Massively Multip... | Free to Play;Massively Multiplayer;Puzzle | 220 | 107 | 0.00 | Every activity in Puzzle Pirates is a uniquely... | 94800 | Mostly Positive |
| 5704 | openCanvas 7 | 2017-09-20 | 1 | PGN Inc | PGN Inc | windows | 0 | Steam Trading Cards | Design & Illustration;Photo Editing | Design & Illustration;Photo Editing | 0 | 2583 | 45.00 | openCanvas is a painting software dedicated to... | 7697 | Mostly Positive |
| 5801 | Shakes and Fidget Remastered | 2018-11-22 | 1 | Playa Games GmbH | Playa Games GmbH | windows | 0 | Single-player;MMO;Cross-Platform Multiplayer;I... | Adventure;Casual;Free to Play;Indie;RPG;Strategy | Free to Play;RPG;Casual | 0 | 50 | 0.00 | Shakes and Fidget is a fun fantasy RPG satire ... | 11818 | Mixed |
| 5857 | Higurashi When They Cry Hou - Ch.3 Tatarigoroshi | 2016-06-17 | 1 | 07th Expansion | MangaGamer | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure | Visual Novel;Anime;Adventure | 16 | 476 | 5.59 | Higurashi When They Cry is a sound novel. The ... | 9464 | Very Positive |
| 5950 | Doodle God | 2015-09-24 | 1 | JoyBits Ltd. | JoyBits Ltd. | windows;mac;linux | 0 | Single-player;Steam Achievements;Full controll... | Casual;Indie;Simulation | Indie;Casual;Puzzle | 22 | 363 | 8.99 | Doodle God is an addicting puzzle & world ... | 39990 | Mostly Positive |
| 5979 | KARAKARA2 | 2017-11-10 | 1 | calme | Sekai Project | windows | 0 | Single-player;Steam Trading Cards;Steam Cloud | Casual;Indie | Sexual Content;Nudity;Indie | 0 | 751 | 7.19 | KARAKARA. It is the sound of aridity. It is th... | 17544 | Very Positive |
| 6018 | Mola mola: Vivienne | 2019-02-28 | 1 | Mola game | Mola game | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;RPG;Simulation;Strategy | Nudity;Sexual Content;Casual | 100 | 6 | 0.79 | Casual decompression game, easy to experience ... | 10512 | Positive |
| 6411 | Zup! X | 2018-05-17 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Minimalist | 2880 | 65 | 0.79 | Minimal physical puzzle with explosions | 34884 | Very Positive |
| 6557 | Zup! | 2016-10-04 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Casual;Indie;Puzzle | 118 | 237 | 0.79 | Minimal physical puzzle with explosions | 321152 | Very Positive |
| 6647 | Zup! 8 | 2018-02-22 | 1 | Quiet River | Quiet River | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Indie;Casual;Singleplayer | 2220 | 193 | 0.79 | Minimal physical puzzle with explosions | 36784 | Very Positive |
| 6766 | Major\Minor - Complete Edition | 2016-10-11 | 1 | Klace | Tall Tail Studios | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Indie;RPG;Simulation | Visual Novel;Indie;Adventure | 136 | 0 | 14.99 | A highly engaging visual novel, with memorable... | 25740 | Mostly Positive |
| 6882 | Lines X | 2017-10-31 | 1 | Konstructors Entertainment | Konstructors Entertainment | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Cloud | Casual;Indie;Strategy | Casual;Indie;Strategy | 590 | 0 | 0.79 | Beautiful & relaxing Numberlink puzzles. | 17587 | Mostly Positive |
| 7125 | Achievement Clicker 2019 | 2018-04-13 | 1 | OfficialAndy | MGG Studio | windows | 0 | Single-player;Steam Achievements | Adventure;Casual;Indie;Simulation;Strategy | Strategy;Indie;Casual | 50 | 0 | 0.79 | Feel like a real Achievement hunter! Earn Achi... | 4598 | Mixed |
| 7463 | Oik 2 | 2017-03-28 | 1 | Crew Lab | Crew Lab | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Indie;Casual;Puzzle | 365 | 140 | 0.79 | Casual physics puzzle | 37969 | Very Positive |
| 7768 | Faerie Solitaire | 2010-09-17 | 1 | Subsoap | Subsoap | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | Card Game;Casual;Indie | 30 | 266 | 6.99 | Have magical fun in the addicting Card game, F... | 185966 | Very Positive |
Debido a que son una cantidad no tan grande de datos y que no son juegos muestras duplicadas del mismo juego, si no versiones distintas del mismo juego.
A continuación se observa en detalle el comportamiento de las siguientes vairables de interés:
px.histogram(df_train,
x='rating',
title='Análisis de la variable rating',
marginal='box'
)
Notemos que existe una distribución balanceada entre cada categoría. Si bien no existe una cantidad pareja, la diferencias se mantienen en magnitudes razonables.
px.histogram(df_train,
x='required_age',
title='Análisis de la variable required_age',
marginal='box'
)
La gran mayoría de los juegos no tiene restricción de edad. Esto nos dice, en cierta medida, que no tiene tanta importancia en la predicción.
px.histogram(df_train,
x='price',
title='Análisis de la variable price',
marginal='box'
)
La distribución de los precios se acumula en valores inferiores a los 20 dolares. Es probable que la gran mayoría de juegos indies se concentren aquí, mientras que los juegos de grandes compañías tengan valores mucho mayores.
A continuación, comenzamos a crear los primeros n-gramas que nos ayudarán en la predicción y a evaluar la composición del dataset.
from nltk.util import ngrams
from collections import Counter
from wordcloud import WordCloud
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
from spacy.lang.en.stop_words import STOP_WORDS
import spacy
import re
from nltk import bigrams
from nltk import trigrams
stop_words = set(stopwords.words('english')).union(set(STOP_WORDS))
#Palabras más frecuentes
desc_total=df_train['short_description']
corpus = []
for desc in desc_total:
for word in desc.split():
corpus.append(word)
import en_core_web_lg
nlp = spacy.load('en_core_web_lg')
nlp.max_length = 1720000
from operator import itemgetter
import collections
def most_frequent_ngrams(corpus, n, stop_words):
"""
corpus: lista de n-grams
n: n=2 para 2-grams, n=3 para 3-grams, etc
"""
freq = collections.defaultdict( int )
for w in corpus:
freq[w] += 1
freq = sorted(freq.items(), key=itemgetter(1), reverse=True)
x, y= [], []
for word,count in freq[:20]:
if (word not in stop_words):
x.append(word)
y.append(count)
x=[" ".join(v) for v in x]
fig = px.bar(x=y, y=x)
fig.show()
#return x, y
corpus = [word.lemma_ for word in nlp(' '.join(corpus))]
corpus = [x for x in corpus if x not in stop_words]
corpus = [x for x in corpus if x == re.sub(r'[^\w\s]', '', x)]
A continuación se observan los trigramas y bigramas más frecuentes del bag of words creado para el dataset.
trigram = trigrams(corpus)
most_frequent_ngrams(trigram, 3, stop_words)
bigram = bigrams(corpus)
most_frequent_ngrams(bigram, 2, stop_words)
Un aspecto relevante es que la descripción del juego se condice mucho con los valores de las categorías. Esto nos podría generar correlaciones no deseadas más adelante.
A continuación se observa la correlación entre las variables de entrada y la variable por predecir:
correlations_df = df_train[['required_age','achievements','average_playtime','price','estimated_sells']]
Para esto extraemos las variables objetivo en un inicio:
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MinMaxScaler, OneHotEncoder, StandardScaler
labels = df_train.loc[:, ["rating"]]
labels
encoder = OneHotEncoder(sparse=False)
encoded_labels = encoder.fit_transform(labels)
encoded_labels_df = pd.DataFrame(encoded_labels, columns=encoder.get_feature_names())
encoded_labels_df
| x0_Mixed | x0_Mostly Positive | x0_Negative | x0_Positive | x0_Very Positive | |
|---|---|---|---|---|---|
| 0 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 1 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 2 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 |
| 3 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 |
| 4 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 |
| ... | ... | ... | ... | ... | ... |
| 7876 | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 |
| 7877 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
| 7878 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 |
| 7879 | 0.0 | 1.0 | 0.0 | 0.0 | 0.0 |
| 7880 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
7881 rows × 5 columns
Notemos que, salvo x0_negative con price y x0_VeryPositive con estimated sells, las magnitudes de correlación son bajas.
correlations_labels_df = pd.concat([correlations_df, encoded_labels_df], axis=1)
correlations_labels = correlations_labels_df.corr('pearson').iloc[5:, 0:5]
px.imshow(correlations_labels,
labels=dict(x="", y="", color="Correlation"),
x=correlations_labels.columns,
y=correlations_labels.index,
zmin=-1,
zmax=1,
color_continuous_scale="PRgn")
A continuación, buscamos reducir la dimensionalidad del dataset debido a los resultados anteriores.
#features=pd.get_dummies(features)
features=df_train[['required_age','achievements','average_playtime','price','estimated_sells']]
scaled_features = StandardScaler().fit_transform(features)
umap = umap.UMAP()
df_train_umap_embedded = umap.fit_transform(scaled_features)
df_train_umap_embedded
array([[-0.7290677 , 0.60387987],
[12.488004 , 17.94498 ],
[ 8.606597 , 8.516323 ],
...,
[-5.357761 , 12.333541 ],
[10.016366 , 17.903786 ],
[11.057879 , 6.957377 ]], dtype=float32)
df_train['x_umap'] = df_train_umap_embedded[:, 0]
df_train['y_umap'] = df_train_umap_embedded[:, 1]
px.scatter(
df_train,
x='x_umap',
y='y_umap',
color='price',
)
px.scatter(
df_train,
x='x_umap',
y='y_umap',
color='rating',
)
px.scatter(
df_train,
x='x_umap',
y='y_umap',
color='platforms',
)
Al efectuar el análisis exploratorio de datos con Pandas Profiling pudimos notar lo siguiente:
No se presentan datos nulos en el conjunto de entrenamiento de las 11 variables categoricas y las 5 numericas.
De las variables que presentan valores duplicados se destacan 'english' que puede presentar poca información a los modelos dado que las clases estan desbalanceadas. Tambien se puede apreciar que 'short_description' tiene valores duplicados pero al ver los valores son diferentes versiones del mismo juego.
Tambien variables como 'achievements', 'average_playtime', 'estimated_sells' presentan valores que muy extremos a los comparado con el grueso de la muestra lo que se podrian estudiar para ver si corresponden a outliers y si vale la pena eliminarlos.
Por otro lado se puede observar que la variable 'price' presenta una distribuciòn Poisson. Tambien, se aprecia a traves de la matriz de correlaciòn de Spearman del Pandas Profiling que de la mayoria de las variables entre si no hay correlación entre ellas, pero se destaca una mayor correlación positiva entre las varibales 'estimated_sells' con 'averge_playtime' y otra relación importante es 'price' con 'achievements'. No se observan interacciones entre variables.
Mientras que con la reducción de dimensionalidad con UMAP, se puede notar que las variables separan en grupos en donde con la variable 'price' se aprecia diferencia hacia los juegos mas caros.
Para preparar nuestros datos, primero como se comento en la parte anterior se ve que no hay elementos duplicados en la tabla en general, pero si en columnas como 'short_description' dado que por el nombre de los juegos, se encuentran con nombre parecidos pero diferentes versiones, se procede a dejar todos los datos. A continuación se trabajan los outliers del dataset. El criterio que se usar, para las variables numéricas, es aplicar z-score y ver que los valores esten dentro de un 95% de confianza. Partimos analizando la variable precio.
from scipy.stats import zscore
z_scores = zscore(df_train['price'])
z_scores
array([-0.9630193 , 0.29224724, -0.16462866, ..., -0.63292646,
0.29224724, -0.16462866])
df_train['price_zscores'] = z_scores
df_train['price_outlier'] = df_train['price_zscores'].abs() > 3
df_train[['price', 'price_zscores', 'price_outlier']].head(10)
| price | price_zscores | price_outlier | |
|---|---|---|---|
| 0 | 0.00 | -0.963019 | False |
| 1 | 10.99 | 0.292247 | False |
| 2 | 6.99 | -0.164629 | False |
| 3 | 0.00 | -0.963019 | False |
| 4 | 7.99 | -0.050410 | False |
| 5 | 0.75 | -0.877355 | False |
| 6 | 27.79 | 2.211126 | False |
| 7 | 1.99 | -0.735724 | False |
| 8 | 19.49 | 1.263109 | False |
| 9 | 0.00 | -0.963019 | False |
df_train['price_outlier'].value_counts()
False 7696 True 185 Name: price_outlier, dtype: int64
En total hay 105 outliers en la variables precio.
z_scores = zscore(df_train['average_playtime'])
df_train['average_playtime_zscores'] = z_scores
df_train['average_playtime_outlier'] = df_train['average_playtime_zscores'].abs() > 3
df_train[['average_playtime', 'average_playtime_zscores', 'average_playtime_outlier']].head(10)
| average_playtime | average_playtime_zscores | average_playtime_outlier | |
|---|---|---|---|
| 0 | 0 | -0.133001 | False |
| 1 | 65 | -0.113322 | False |
| 2 | 217 | -0.067302 | False |
| 3 | 1240 | 0.242420 | False |
| 4 | 245 | -0.058825 | False |
| 5 | 237 | -0.061247 | False |
| 6 | 5017 | 1.385943 | False |
| 7 | 274 | -0.050045 | False |
| 8 | 0 | -0.133001 | False |
| 9 | 513 | 0.022314 | False |
df_train['average_playtime_outlier'].value_counts()
False 7840 True 41 Name: average_playtime_outlier, dtype: int64
y también existen 41 en la variable _averageplaytime
data_1=df_train[df_train['average_playtime_outlier']!=True]
data_1=data_1[data_1['price_outlier']!=True].reset_index()
data_1
| index | name | release_date | english | developer | publisher | platforms | required_age | categories | genres | ... | achievements | average_playtime | price | short_description | estimated_sells | rating | price_zscores | price_outlier | average_playtime_zscores | average_playtime_outlier | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | An Aspie Life | 2018-03-29 | 1 | Bradley Hennessey;Joe Watson | EnderLost Studios | windows | 0 | Single-player;Steam Achievements | Adventure;Casual;Free to Play;Indie;Simulation | ... | 23 | 0 | 0.00 | One day your roommate Leaves for no reason. Yo... | 3914 | Mixed | -0.963019 | False | -0.133001 | False |
| 1 | 1 | GhostControl Inc. | 2014-06-06 | 1 | bumblebee | Application Systems Heidelberg | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie;Simulation;Strategy | ... | 53 | 65 | 10.99 | Manage a team of ghosthunters and free London ... | 10728 | Mixed | 0.292247 | False | -0.113322 | False |
| 2 | 2 | Deponia | 2012-08-06 | 1 | Daedalic Entertainment | Daedalic Entertainment | windows;mac;linux | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Indie | ... | 19 | 217 | 6.99 | In Deponia, the world has degenerated into a v... | 635792 | Positive | -0.164629 | False | -0.067302 | False |
| 3 | 3 | Atlas Reactor | 2016-10-04 | 1 | Trion Worlds | Trion Worlds | windows | 0 | Multi-player;Online Multi-Player;Steam Achieve... | Free to Play;Strategy | ... | 121 | 1240 | 0.00 | SEASON 6 NOW LIVE! The battle for Atlas contin... | 253864 | Positive | -0.963019 | False | 0.242420 | False |
| 4 | 4 | CHUCHEL | 2018-03-07 | 1 | Amanita Design | Amanita Design | windows;mac | 0 | Single-player;Steam Achievements;Steam Trading... | Adventure;Casual;Indie | ... | 7 | 245 | 7.99 | CHUCHEL is a comedy adventure game from the cr... | 49818 | Mostly Positive | -0.050410 | False | -0.058825 | False |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 7654 | 7876 | KOEWOTAYORINI / 声之寄托 | 2018-03-26 | 0 | あみそ組 | Pujia8 Studio;Gamera Game | windows | 0 | Single-player;Steam Achievements;Steam Cloud | Adventure;Free to Play;Indie;RPG | ... | 20 | 65 | 0.00 | “喂喂,求求你啦!救救我!” ——你接到这样一个电话 发出这样的求救,给你打电话的人,是一名... | 24130 | Positive | -0.963019 | False | -0.113322 | False |
| 7655 | 7877 | Montaro | 2016-07-25 | 1 | JCKSLAP | MBDL | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | ... | 15 | 174 | 0.79 | Montaro is a DOGE. | 550368 | Very Positive | -0.872786 | False | -0.080321 | False |
| 7656 | 7878 | Moe Jigsaw | 2018-03-23 | 1 | ARES Inc. | ARES Inc. | windows | 0 | Single-player;Steam Achievements;Steam Trading... | Casual;Indie | ... | 72 | 0 | 2.89 | "Moe Jigsaw" is the definitive versi... | 10906 | Mostly Positive | -0.632926 | False | -0.133001 | False |
| 7657 | 7879 | Drunkn Bar Fight | 2016-11-28 | 1 | The Munky | The Munky | windows | 0 | Single-player;Multi-player;Online Multi-Player... | Action;Indie;Early Access | ... | 0 | 0 | 10.99 | VR PARTY GAMEDrunkn Bar Fight is a simple, imm... | 18876 | Mostly Positive | 0.292247 | False | -0.133001 | False |
| 7658 | 7880 | Intake | 2013-11-06 | 1 | Cipher Prime Studios | Cipher Prime Studios | windows;mac | 0 | Single-player;Steam Achievements;Steam Cloud;S... | Action;Indie | ... | 77 | 75 | 6.99 | Intake is the new retro-futuristic drugstep ar... | 29625 | Very Positive | -0.164629 | False | -0.110294 | False |
7659 rows × 21 columns
Después, como no existen dados faltantes no se procede a hacer imputación de datos y se procede a aplicar ColumnTransformer para prepara los datos:
# Definimos algunas stopword que queremos que sean eliminadas
from nltk import word_tokenize
# Definimos un tokenizador con Stemming
class StemmerTokenizer:
def __init__(self):
self.ps = PorterStemmer()
def __call__(self, doc):
doc_tok = word_tokenize(doc)
doc_tok = [t for t in doc_tok if t not in stop_words]
return [self.ps.stem(t) for t in doc_tok]
# Inicializamos tokenizador
tokenizador = StemmerTokenizer()
from sklearn.preprocessing import OneHotEncoder
bog = CountVectorizer(tokenizer= StemmerTokenizer(),
stop_words=stop_words,
ngram_range=(1,2)
)
ct_clf = ColumnTransformer(
[
("StandardScaler",StandardScaler(),
[
'required_age',
'achievements',
'average_playtime',
'price'
],
),
("Bow", bog, "short_description"),
("OneHot", OneHotEncoder(sparse=False,handle_unknown ='ignore'), ["publisher","platforms",
"categories","genres"])
]
)
Para la clasificación se aplicó Standard scaler con sus valores por defecto y bigramas dentro del bag o words.
pipe = Pipeline([('Preprocessing', ct_clf)])
df_preprocesado = pipe.fit_transform(data_1)
df_preprocesado = pd.DataFrame(df_preprocesado.toarray())
df_preprocesado
C:\Users\admin\anaconda3\lib\site-packages\sklearn\feature_extraction\text.py:388: UserWarning: Your stop_words may be inconsistent with your preprocessing. Tokenizing the stop words generated tokens ['n', 'need', 'sha', 'wo', '‘', '’'] not in stop_words.
warnings.warn('Your stop_words may be inconsistent with '
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 139755 | 139756 | 139757 | 139758 | 139759 | 139760 | 139761 | 139762 | 139763 | 139764 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -0.212805 | -0.074128 | -0.350920 | -1.094147 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 1 | -0.212805 | 0.037516 | -0.264091 | 0.483156 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 2 | -0.212805 | -0.089013 | -0.061047 | -0.090931 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 3 | -0.212805 | 0.290574 | 1.305497 | -1.094147 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 4 | -0.212805 | -0.133671 | -0.023644 | 0.052591 | 1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 7654 | -0.212805 | -0.085292 | -0.264091 | -1.094147 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 7655 | -0.212805 | -0.103899 | -0.118487 | -0.980765 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 7656 | -0.212805 | 0.108223 | -0.350920 | -0.679369 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 7657 | -0.212805 | -0.159721 | -0.350920 | 0.483156 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 7658 | -0.212805 | 0.126830 | -0.250733 | -0.090931 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
7659 rows × 139765 columns
ct_rg = ColumnTransformer(
[
("MinMax",MinMaxScaler(),
[
'required_age',
'achievements',
'average_playtime',
'price'
],
),
#("Bow", bog, "short_description"),
("OneHot", OneHotEncoder(sparse=False,handle_unknown ='ignore'), ["publisher","platforms",
"categories",
"genres"])
]
)
pipe = Pipeline([('Preprocessing', ct_rg)])
df_preprocesado = pipe.fit_transform(data_1)
...
Adjuntamos las transformaciones anteriores en un solo Pipeline y agregamos al final un clasificador sencillo ClasificadorX
from sklearn import linear_model
from sklearn import svm
from sklearn.svm import SVC
from sklearn.decomposition import PCA
from sklearn.decomposition import TruncatedSVD
labels = data_1.loc[:, 'rating']
features = data_1.drop(columns=['estimated_sells','rating','index','name','release_date','index','name','release_date'
,'price_zscores','price_outlier','average_playtime_zscores',
'average_playtime_outlier'])
X_train_clf, X_test_clf, y_train_clf, y_test_clf = train_test_split(features,
labels,
test_size=0.33,
random_state=50,
shuffle=True,
stratify=labels)
pipeline_clf = Pipeline(steps=[
("Preprocessing", ct_clf),
("Selection", SelectPercentile(f_classif, percentile=90)),
("clf", KNeighborsClassifier()),
])
pipeline_clf.fit(X_train_clf, y_train_clf)
y_pred_clf = pipeline_clf.predict(X_test_clf)
C:\Users\admin\anaconda3\lib\site-packages\sklearn\feature_extraction\text.py:388: UserWarning: Your stop_words may be inconsistent with your preprocessing. Tokenizing the stop words generated tokens ['n', 'need', 'sha', 'wo', '‘', '’'] not in stop_words.
warnings.warn('Your stop_words may be inconsistent with '
from sklearn.metrics import confusion_matrix, classification_report
print("Matriz de confusión\n\n", confusion_matrix(y_test_clf, y_pred_clf), "\n")
print(classification_report(y_test_clf, y_pred_clf))
Matriz de confusión
[[ 49 193 33 239 13]
[ 52 178 33 258 22]
[ 38 157 46 169 7]
[ 56 218 28 332 18]
[ 40 125 13 190 21]]
precision recall f1-score support
Mixed 0.21 0.09 0.13 527
Mostly Positive 0.20 0.33 0.25 543
Negative 0.30 0.11 0.16 417
Positive 0.28 0.51 0.36 652
Very Positive 0.26 0.05 0.09 389
accuracy 0.25 2528
macro avg 0.25 0.22 0.20 2528
weighted avg 0.25 0.25 0.21 2528
Los resultados son, en general, malos, ya que no se alcanza a tener una exactitud superior al 0.5. Sin embargo, teniendo en cuenta la cantidad de categorías otorga resultados satisfactorios.
labels = data_1.loc[:, 'estimated_sells']
features = data_1.drop(columns=['estimated_sells','rating','index','name','release_date','index','name','release_date'
,'price_zscores','price_outlier','average_playtime_zscores',
'average_playtime_outlier'])
X_train_rg, X_test_rg, y_train_rg, y_test_rg = train_test_split(features,
labels,
test_size=0.33,
random_state=50,
shuffle=True)
pipeline_rg = Pipeline(steps=[
("Preprocessing", ct_rg),
("Selection", SelectPercentile(f_classif, percentile=90)),
("clf", linear_model.Ridge()),
])
reg_pipe = pipeline_rg.fit(X_train_rg, y_train_rg)
C:\Users\admin\anaconda3\lib\site-packages\sklearn\feature_selection\_univariate_selection.py:116: RuntimeWarning: divide by zero encountered in true_divide f = msb / msw
y_pred_rg = reg_pipe.predict(X_test_rg)
y_pred_rg
array([-73234.58122714, 43515.3947065 , 845685.05367322, ...,
136721.72327895, -74641.96200978, 243165.35817447])
print(f'El coeficiente R^2 es: {reg_pipe.score(X_test_rg,y_test_rg)}')
El coeficiente R^2 es: 0.2008684910558427
Nuestro modelo solo explica un 20% de la varianza. Consideramos como grupo que es un valor decente para la complejidad del problema.
Ahora, agregamos selección y/o reducción de atributos y probaremos una combinación de diferentes parámetros para mejorar nuestro modelo:
Nota: Procuren hacer Gridsearch sobre espacios de búsqueda razonables. Es decir, no estén 3 días buscando la mejor configuración...
parametros para la clasificación
pipeline_clf.get_params()
{'memory': None,
'steps': [('Preprocessing',
ColumnTransformer(transformers=[('StandardScaler', StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m",
"'re", "'s", "'ve",
'a', 'about',
'above', 'across',
'after',
'afterwards',
'again', 'against',
'ain', 'all',
'almost', 'alone',
'along', 'already',
'also', 'although',
'always', 'am',
'among', 'amongst',
'amount', 'an',
'and', 'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000002D3F845A280>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['publisher', 'platforms', 'categories',
'genres'])])),
('Selection', SelectPercentile(percentile=90)),
('clf', KNeighborsClassifier())],
'verbose': False,
'Preprocessing': ColumnTransformer(transformers=[('StandardScaler', StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m",
"'re", "'s", "'ve",
'a', 'about',
'above', 'across',
'after',
'afterwards',
'again', 'against',
'ain', 'all',
'almost', 'alone',
'along', 'already',
'also', 'although',
'always', 'am',
'among', 'amongst',
'amount', 'an',
'and', 'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000002D3F845A280>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['publisher', 'platforms', 'categories',
'genres'])]),
'Selection': SelectPercentile(percentile=90),
'clf': KNeighborsClassifier(),
'Preprocessing__n_jobs': None,
'Preprocessing__remainder': 'drop',
'Preprocessing__sparse_threshold': 0.3,
'Preprocessing__transformer_weights': None,
'Preprocessing__transformers': [('StandardScaler',
StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m", "'re", "'s", "'ve", 'a', 'about',
'above', 'across', 'after', 'afterwards', 'again',
'against', 'ain', 'all', 'almost', 'alone', 'along',
'already', 'also', 'although', 'always', 'am',
'among', 'amongst', 'amount', 'an', 'and',
'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000002D3F845A280>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore', sparse=False),
['publisher', 'platforms', 'categories', 'genres'])],
'Preprocessing__verbose': False,
'Preprocessing__StandardScaler': StandardScaler(),
'Preprocessing__Bow': CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m", "'re", "'s", "'ve", 'a', 'about',
'above', 'across', 'after', 'afterwards', 'again',
'against', 'ain', 'all', 'almost', 'alone', 'along',
'already', 'also', 'although', 'always', 'am',
'among', 'amongst', 'amount', 'an', 'and',
'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000002D3F845A280>),
'Preprocessing__OneHot': OneHotEncoder(handle_unknown='ignore', sparse=False),
'Preprocessing__StandardScaler__copy': True,
'Preprocessing__StandardScaler__with_mean': True,
'Preprocessing__StandardScaler__with_std': True,
'Preprocessing__Bow__analyzer': 'word',
'Preprocessing__Bow__binary': False,
'Preprocessing__Bow__decode_error': 'strict',
'Preprocessing__Bow__dtype': numpy.int64,
'Preprocessing__Bow__encoding': 'utf-8',
'Preprocessing__Bow__input': 'content',
'Preprocessing__Bow__lowercase': True,
'Preprocessing__Bow__max_df': 1.0,
'Preprocessing__Bow__max_features': None,
'Preprocessing__Bow__min_df': 1,
'Preprocessing__Bow__ngram_range': (1, 2),
'Preprocessing__Bow__preprocessor': None,
'Preprocessing__Bow__stop_words': {"'d",
"'ll",
"'m",
"'re",
"'s",
"'ve",
'a',
'about',
'above',
'across',
'after',
'afterwards',
'again',
'against',
'ain',
'all',
'almost',
'alone',
'along',
'already',
'also',
'although',
'always',
'am',
'among',
'amongst',
'amount',
'an',
'and',
'another',
'any',
'anyhow',
'anyone',
'anything',
'anyway',
'anywhere',
'are',
'aren',
"aren't",
'around',
'as',
'at',
'back',
'be',
'became',
'because',
'become',
'becomes',
'becoming',
'been',
'before',
'beforehand',
'behind',
'being',
'below',
'beside',
'besides',
'between',
'beyond',
'both',
'bottom',
'but',
'by',
'ca',
'call',
'can',
'cannot',
'could',
'couldn',
"couldn't",
'd',
'did',
'didn',
"didn't",
'do',
'does',
'doesn',
"doesn't",
'doing',
'don',
"don't",
'done',
'down',
'due',
'during',
'each',
'eight',
'either',
'eleven',
'else',
'elsewhere',
'empty',
'enough',
'even',
'ever',
'every',
'everyone',
'everything',
'everywhere',
'except',
'few',
'fifteen',
'fifty',
'first',
'five',
'for',
'former',
'formerly',
'forty',
'four',
'from',
'front',
'full',
'further',
'get',
'give',
'go',
'had',
'hadn',
"hadn't",
'has',
'hasn',
"hasn't",
'have',
'haven',
"haven't",
'having',
'he',
'hence',
'her',
'here',
'hereafter',
'hereby',
'herein',
'hereupon',
'hers',
'herself',
'him',
'himself',
'his',
'how',
'however',
'hundred',
'i',
'if',
'in',
'indeed',
'into',
'is',
'isn',
"isn't",
'it',
"it's",
'its',
'itself',
'just',
'keep',
'last',
'latter',
'latterly',
'least',
'less',
'll',
'm',
'ma',
'made',
'make',
'many',
'may',
'me',
'meanwhile',
'might',
'mightn',
"mightn't",
'mine',
'more',
'moreover',
'most',
'mostly',
'move',
'much',
'must',
'mustn',
"mustn't",
'my',
'myself',
"n't",
'name',
'namely',
'needn',
"needn't",
'neither',
'never',
'nevertheless',
'next',
'nine',
'no',
'nobody',
'none',
'noone',
'nor',
'not',
'nothing',
'now',
'nowhere',
'n‘t',
'n’t',
'o',
'of',
'off',
'often',
'on',
'once',
'one',
'only',
'onto',
'or',
'other',
'others',
'otherwise',
'our',
'ours',
'ourselves',
'out',
'over',
'own',
'part',
'per',
'perhaps',
'please',
'put',
'quite',
'rather',
're',
'really',
'regarding',
's',
'same',
'say',
'see',
'seem',
'seemed',
'seeming',
'seems',
'serious',
'several',
'shan',
"shan't",
'she',
"she's",
'should',
"should've",
'shouldn',
"shouldn't",
'show',
'side',
'since',
'six',
'sixty',
'so',
'some',
'somehow',
'someone',
'something',
'sometime',
'sometimes',
'somewhere',
'still',
'such',
't',
'take',
'ten',
'than',
'that',
"that'll",
'the',
'their',
'theirs',
'them',
'themselves',
'then',
'thence',
'there',
'thereafter',
'thereby',
'therefore',
'therein',
'thereupon',
'these',
'they',
'third',
'this',
'those',
'though',
'three',
'through',
'throughout',
'thru',
'thus',
'to',
'together',
'too',
'top',
'toward',
'towards',
'twelve',
'twenty',
'two',
'under',
'unless',
'until',
'up',
'upon',
'us',
'used',
'using',
'various',
've',
'very',
'via',
'was',
'wasn',
"wasn't",
'we',
'well',
'were',
'weren',
"weren't",
'what',
'whatever',
'when',
'whence',
'whenever',
'where',
'whereafter',
'whereas',
'whereby',
'wherein',
'whereupon',
'wherever',
'whether',
'which',
'while',
'whither',
'who',
'whoever',
'whole',
'whom',
'whose',
'why',
'will',
'with',
'within',
'without',
'won',
"won't",
'would',
'wouldn',
"wouldn't",
'y',
'yet',
'you',
"you'd",
"you'll",
"you're",
"you've",
'your',
'yours',
'yourself',
'yourselves',
'‘d',
'‘ll',
'‘m',
'‘re',
'‘s',
'‘ve',
'’d',
'’ll',
'’m',
'’re',
'’s',
'’ve'},
'Preprocessing__Bow__strip_accents': None,
'Preprocessing__Bow__token_pattern': '(?u)\\b\\w\\w+\\b',
'Preprocessing__Bow__tokenizer': <__main__.StemmerTokenizer at 0x2d3f845a280>,
'Preprocessing__Bow__vocabulary': None,
'Preprocessing__OneHot__categories': 'auto',
'Preprocessing__OneHot__drop': None,
'Preprocessing__OneHot__dtype': numpy.float64,
'Preprocessing__OneHot__handle_unknown': 'ignore',
'Preprocessing__OneHot__sparse': False,
'Selection__percentile': 90,
'Selection__score_func': <function sklearn.feature_selection._univariate_selection.f_classif(X, y)>,
'clf__algorithm': 'auto',
'clf__leaf_size': 30,
'clf__metric': 'minkowski',
'clf__metric_params': None,
'clf__n_jobs': None,
'clf__n_neighbors': 5,
'clf__p': 2,
'clf__weights': 'uniform'}
pipeline_clf.get_params()
{'memory': None,
'steps': [('Preprocessing',
ColumnTransformer(transformers=[('StandardScaler', StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m",
"'re", "'s", "'ve",
'a', 'about',
'above', 'across',
'after',
'afterwards',
'again', 'against',
'ain', 'all',
'almost', 'alone',
'along', 'already',
'also', 'although',
'always', 'am',
'among', 'amongst',
'amount', 'an',
'and', 'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000001C30CE7B0A0>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])])),
('Selection', SelectPercentile(percentile=90)),
('clf', KNeighborsClassifier())],
'verbose': False,
'Preprocessing': ColumnTransformer(transformers=[('StandardScaler', StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m",
"'re", "'s", "'ve",
'a', 'about',
'above', 'across',
'after',
'afterwards',
'again', 'against',
'ain', 'all',
'almost', 'alone',
'along', 'already',
'also', 'although',
'always', 'am',
'among', 'amongst',
'amount', 'an',
'and', 'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000001C30CE7B0A0>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])]),
'Selection': SelectPercentile(percentile=90),
'clf': KNeighborsClassifier(),
'Preprocessing__n_jobs': None,
'Preprocessing__remainder': 'drop',
'Preprocessing__sparse_threshold': 0.3,
'Preprocessing__transformer_weights': None,
'Preprocessing__transformers': [('StandardScaler',
StandardScaler(),
['average_playtime', 'price']),
('Bow',
CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m", "'re", "'s", "'ve", 'a', 'about',
'above', 'across', 'after', 'afterwards', 'again',
'against', 'ain', 'all', 'almost', 'alone', 'along',
'already', 'also', 'although', 'always', 'am',
'among', 'amongst', 'amount', 'an', 'and',
'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000001C30CE7B0A0>),
'short_description'),
('OneHot',
OneHotEncoder(handle_unknown='ignore', sparse=False),
['english',
'developer',
'publisher',
'platforms',
'categories',
'genres',
'tags'])],
'Preprocessing__verbose': False,
'Preprocessing__StandardScaler': StandardScaler(),
'Preprocessing__Bow': CountVectorizer(ngram_range=(1, 2),
stop_words={"'d", "'ll", "'m", "'re", "'s", "'ve", 'a', 'about',
'above', 'across', 'after', 'afterwards', 'again',
'against', 'ain', 'all', 'almost', 'alone', 'along',
'already', 'also', 'although', 'always', 'am',
'among', 'amongst', 'amount', 'an', 'and',
'another', ...},
tokenizer=<__main__.StemmerTokenizer object at 0x000001C30CE7B0A0>),
'Preprocessing__OneHot': OneHotEncoder(handle_unknown='ignore', sparse=False),
'Preprocessing__StandardScaler__copy': True,
'Preprocessing__StandardScaler__with_mean': True,
'Preprocessing__StandardScaler__with_std': True,
'Preprocessing__Bow__analyzer': 'word',
'Preprocessing__Bow__binary': False,
'Preprocessing__Bow__decode_error': 'strict',
'Preprocessing__Bow__dtype': numpy.int64,
'Preprocessing__Bow__encoding': 'utf-8',
'Preprocessing__Bow__input': 'content',
'Preprocessing__Bow__lowercase': True,
'Preprocessing__Bow__max_df': 1.0,
'Preprocessing__Bow__max_features': None,
'Preprocessing__Bow__min_df': 1,
'Preprocessing__Bow__ngram_range': (1, 2),
'Preprocessing__Bow__preprocessor': None,
'Preprocessing__Bow__stop_words': {"'d",
"'ll",
"'m",
"'re",
"'s",
"'ve",
'a',
'about',
'above',
'across',
'after',
'afterwards',
'again',
'against',
'ain',
'all',
'almost',
'alone',
'along',
'already',
'also',
'although',
'always',
'am',
'among',
'amongst',
'amount',
'an',
'and',
'another',
'any',
'anyhow',
'anyone',
'anything',
'anyway',
'anywhere',
'are',
'aren',
"aren't",
'around',
'as',
'at',
'back',
'be',
'became',
'because',
'become',
'becomes',
'becoming',
'been',
'before',
'beforehand',
'behind',
'being',
'below',
'beside',
'besides',
'between',
'beyond',
'both',
'bottom',
'but',
'by',
'ca',
'call',
'can',
'cannot',
'could',
'couldn',
"couldn't",
'd',
'did',
'didn',
"didn't",
'do',
'does',
'doesn',
"doesn't",
'doing',
'don',
"don't",
'done',
'down',
'due',
'during',
'each',
'eight',
'either',
'eleven',
'else',
'elsewhere',
'empty',
'enough',
'even',
'ever',
'every',
'everyone',
'everything',
'everywhere',
'except',
'few',
'fifteen',
'fifty',
'first',
'five',
'for',
'former',
'formerly',
'forty',
'four',
'from',
'front',
'full',
'further',
'get',
'give',
'go',
'had',
'hadn',
"hadn't",
'has',
'hasn',
"hasn't",
'have',
'haven',
"haven't",
'having',
'he',
'hence',
'her',
'here',
'hereafter',
'hereby',
'herein',
'hereupon',
'hers',
'herself',
'him',
'himself',
'his',
'how',
'however',
'hundred',
'i',
'if',
'in',
'indeed',
'into',
'is',
'isn',
"isn't",
'it',
"it's",
'its',
'itself',
'just',
'keep',
'last',
'latter',
'latterly',
'least',
'less',
'll',
'm',
'ma',
'made',
'make',
'many',
'may',
'me',
'meanwhile',
'might',
'mightn',
"mightn't",
'mine',
'more',
'moreover',
'most',
'mostly',
'move',
'much',
'must',
'mustn',
"mustn't",
'my',
'myself',
"n't",
'name',
'namely',
'needn',
"needn't",
'neither',
'never',
'nevertheless',
'next',
'nine',
'no',
'nobody',
'none',
'noone',
'nor',
'not',
'nothing',
'now',
'nowhere',
'n‘t',
'n’t',
'o',
'of',
'off',
'often',
'on',
'once',
'one',
'only',
'onto',
'or',
'other',
'others',
'otherwise',
'our',
'ours',
'ourselves',
'out',
'over',
'own',
'part',
'per',
'perhaps',
'please',
'put',
'quite',
'rather',
're',
'really',
'regarding',
's',
'same',
'say',
'see',
'seem',
'seemed',
'seeming',
'seems',
'serious',
'several',
'shan',
"shan't",
'she',
"she's",
'should',
"should've",
'shouldn',
"shouldn't",
'show',
'side',
'since',
'six',
'sixty',
'so',
'some',
'somehow',
'someone',
'something',
'sometime',
'sometimes',
'somewhere',
'still',
'such',
't',
'take',
'ten',
'than',
'that',
"that'll",
'the',
'their',
'theirs',
'them',
'themselves',
'then',
'thence',
'there',
'thereafter',
'thereby',
'therefore',
'therein',
'thereupon',
'these',
'they',
'third',
'this',
'those',
'though',
'three',
'through',
'throughout',
'thru',
'thus',
'to',
'together',
'too',
'top',
'toward',
'towards',
'twelve',
'twenty',
'two',
'under',
'unless',
'until',
'up',
'upon',
'us',
'used',
'using',
'various',
've',
'very',
'via',
'was',
'wasn',
"wasn't",
'we',
'well',
'were',
'weren',
"weren't",
'what',
'whatever',
'when',
'whence',
'whenever',
'where',
'whereafter',
'whereas',
'whereby',
'wherein',
'whereupon',
'wherever',
'whether',
'which',
'while',
'whither',
'who',
'whoever',
'whole',
'whom',
'whose',
'why',
'will',
'with',
'within',
'without',
'won',
"won't",
'would',
'wouldn',
"wouldn't",
'y',
'yet',
'you',
"you'd",
"you'll",
"you're",
"you've",
'your',
'yours',
'yourself',
'yourselves',
'‘d',
'‘ll',
'‘m',
'‘re',
'‘s',
'‘ve',
'’d',
'’ll',
'’m',
'’re',
'’s',
'’ve'},
'Preprocessing__Bow__strip_accents': None,
'Preprocessing__Bow__token_pattern': '(?u)\\b\\w\\w+\\b',
'Preprocessing__Bow__tokenizer': <__main__.StemmerTokenizer at 0x1c30ce7b0a0>,
'Preprocessing__Bow__vocabulary': None,
'Preprocessing__OneHot__categories': 'auto',
'Preprocessing__OneHot__drop': None,
'Preprocessing__OneHot__dtype': numpy.float64,
'Preprocessing__OneHot__handle_unknown': 'ignore',
'Preprocessing__OneHot__sparse': False,
'Selection__percentile': 90,
'Selection__score_func': <function sklearn.feature_selection._univariate_selection.f_classif(X, y)>,
'clf__algorithm': 'auto',
'clf__leaf_size': 30,
'clf__metric': 'minkowski',
'clf__metric_params': None,
'clf__n_jobs': None,
'clf__n_neighbors': 5,
'clf__p': 2,
'clf__weights': 'uniform'}
Se prueban una serie de parámetros. En este caso, dos clasificadores distintos: SVM y Regresión Logística, dentro de un espacio de hasta trigramas.
params = [
{'clf': [svm.LinearSVC()],
'clf__C' : np.logspace(-4, 4, 10),
'clf__dual' : (True, False),
'Selection__percentile': [20, 40, 60, 80],
'Preprocessing__Bow__ngram_range':[(1,1), (1,2), (1,3)]
},
{'clf': [LogisticRegression(random_state=50)],
'clf__C' : np.logspace(-4, 4, 10),
'clf__solver' : ['liblinear'],
'Selection__percentile': [20, 40, 60, 80],
'Preprocessing__Bow__ngram_range':[(1,1), (1,2), (1,3)]
},
]
from sklearn.experimental import enable_halving_search_cv # noqa
from sklearn.model_selection import HalvingGridSearchCV
grid=HalvingGridSearchCV(pipeline_clf,params,verbose=10,n_jobs=-1,min_resources=2)
grid.fit(X_train_clf, y_train_clf)
y_pred_clf = grid.predict(X_test_clf)
n_iterations: 6 n_required_iterations: 6 n_possible_iterations: 8 min_resources_: 2 max_resources_: 5131 aggressive_elimination: False factor: 3 ---------- iter: 0 n_candidates: 360 n_resources: 2 Fitting 5 folds for each of 360 candidates, totalling 1800 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan] warnings.warn( C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan] warnings.warn(
---------- iter: 1 n_candidates: 120 n_resources: 6 Fitting 5 folds for each of 120 candidates, totalling 600 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.6 0.6 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.6 nan nan nan 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 nan nan nan nan nan nan nan nan nan 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6] warnings.warn( C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.95 0.95 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 0.95 nan nan nan 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. nan nan nan nan nan nan nan nan nan 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. ] warnings.warn(
---------- iter: 2 n_candidates: 40 n_resources: 18 Fitting 5 folds for each of 40 candidates, totalling 200 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.6 0.6 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.6 nan nan
nan 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.53333333 0.53333333 0.53333333 0.46666667
0.46666667 0.46666667 0.46666667 0.46666667 0.46666667 0.46666667
0.53333333 0.4 0.4 0.33333333 0.33333333 0.4
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.2 0.4 0.4 0.4
0.4 0.53333333 0.53333333 0.4 ]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.95 0.95 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.95 nan nan
nan 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 0.88571429 0.88571429 0.88571429 0.92857143
0.75714286 0.77142857 0.77142857 0.98571429 0.81428571 0.98571429
0.9 0.81428571 0.81428571 0.81428571 0.81428571 0.9
0.9 0.92857143 0.92857143 0.95714286 0.97142857 0.97142857
0.97142857 0.97142857 0.88571429 0.97142857 0.95714286 0.92857143
0.92857143 0.88571429 0.9 0.95714286]
warnings.warn(
---------- iter: 3 n_candidates: 14 n_resources: 54 Fitting 5 folds for each of 14 candidates, totalling 70 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.6 0.6 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.6 nan nan
nan 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.53333333 0.53333333 0.53333333 0.46666667
0.46666667 0.46666667 0.46666667 0.46666667 0.46666667 0.46666667
0.53333333 0.4 0.4 0.33333333 0.33333333 0.4
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.2 0.4 0.4 0.4
0.4 0.53333333 0.53333333 0.4 0.24 0.24
0.24 0.24 0.24 0.24 0.24 0.18
0.28 0.26 0.26 0.26 0.26 0.28 ]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.95 0.95 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.95 nan nan
nan 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 0.88571429 0.88571429 0.88571429 0.92857143
0.75714286 0.77142857 0.77142857 0.98571429 0.81428571 0.98571429
0.9 0.81428571 0.81428571 0.81428571 0.81428571 0.9
0.9 0.92857143 0.92857143 0.95714286 0.97142857 0.97142857
0.97142857 0.97142857 0.88571429 0.97142857 0.95714286 0.92857143
0.92857143 0.88571429 0.9 0.95714286 0.99069767 0.97209302
0.66511628 0.97209302 0.60465116 0.60465116 0.57674419 0.97209302
0.6372093 0.87906977 0.59069767 0.59069767 0.87906977 0.6372093 ]
warnings.warn(
---------- iter: 4 n_candidates: 5 n_resources: 162 Fitting 5 folds for each of 5 candidates, totalling 25 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.6 0.6 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.6 nan nan
nan 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.53333333 0.53333333 0.53333333 0.46666667
0.46666667 0.46666667 0.46666667 0.46666667 0.46666667 0.46666667
0.53333333 0.4 0.4 0.33333333 0.33333333 0.4
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.2 0.4 0.4 0.4
0.4 0.53333333 0.53333333 0.4 0.24 0.24
0.24 0.24 0.24 0.24 0.24 0.18
0.28 0.26 0.26 0.26 0.26 0.28
0.3125 0.3125 0.26875 0.3125 0.3125 ]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.95 0.95 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.95 nan nan
nan 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 0.88571429 0.88571429 0.88571429 0.92857143
0.75714286 0.77142857 0.77142857 0.98571429 0.81428571 0.98571429
0.9 0.81428571 0.81428571 0.81428571 0.81428571 0.9
0.9 0.92857143 0.92857143 0.95714286 0.97142857 0.97142857
0.97142857 0.97142857 0.88571429 0.97142857 0.95714286 0.92857143
0.92857143 0.88571429 0.9 0.95714286 0.99069767 0.97209302
0.66511628 0.97209302 0.60465116 0.60465116 0.57674419 0.97209302
0.6372093 0.87906977 0.59069767 0.59069767 0.87906977 0.6372093
0.5627907 0.5627907 0.88992248 0.64031008 0.64031008]
warnings.warn(
---------- iter: 5 n_candidates: 2 n_resources: 486 Fitting 5 folds for each of 2 candidates, totalling 10 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.6 0.6 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.6 nan nan
nan 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 nan nan nan nan
nan nan nan nan nan 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.6 0.6 0.6 0.6 0.6 0.6
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.53333333 0.53333333 0.53333333 0.46666667
0.46666667 0.46666667 0.46666667 0.46666667 0.46666667 0.46666667
0.53333333 0.4 0.4 0.33333333 0.33333333 0.4
0.4 0.4 0.4 0.4 0.4 0.4
0.4 0.4 0.2 0.4 0.4 0.4
0.4 0.53333333 0.53333333 0.4 0.24 0.24
0.24 0.24 0.24 0.24 0.24 0.18
0.28 0.26 0.26 0.26 0.26 0.28
0.3125 0.3125 0.26875 0.3125 0.3125 0.26185567
0.26185567]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.95 0.95 nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan 0.95 nan nan
nan 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. nan nan nan nan
nan nan nan nan nan 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 1. 1. 1. 1.
1. 1. 0.88571429 0.88571429 0.88571429 0.92857143
0.75714286 0.77142857 0.77142857 0.98571429 0.81428571 0.98571429
0.9 0.81428571 0.81428571 0.81428571 0.81428571 0.9
0.9 0.92857143 0.92857143 0.95714286 0.97142857 0.97142857
0.97142857 0.97142857 0.88571429 0.97142857 0.95714286 0.92857143
0.92857143 0.88571429 0.9 0.95714286 0.99069767 0.97209302
0.66511628 0.97209302 0.60465116 0.60465116 0.57674419 0.97209302
0.6372093 0.87906977 0.59069767 0.59069767 0.87906977 0.6372093
0.5627907 0.5627907 0.88992248 0.64031008 0.64031008 0.47835052
0.47835052]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\feature_extraction\text.py:388: UserWarning: Your stop_words may be inconsistent with your preprocessing. Tokenizing the stop words generated tokens ['n', 'need', 'sha', 'wo', '‘', '’'] not in stop_words.
warnings.warn('Your stop_words may be inconsistent with '
y_pred_clf
array(['Positive', 'Positive', 'Mostly Positive', ..., 'Positive',
'Positive', 'Positive'], dtype=object)
El mejor modelo resulta ser SVC usando un bag of words simple.
grid.best_params_
{'Preprocessing__Bow__ngram_range': (1, 1),
'Selection__percentile': 40,
'clf': LinearSVC(C=0.000774263682681127, dual=False),
'clf__C': 0.000774263682681127,
'clf__dual': False}
A pesar de que los resultados mejoran, no logran obtener una valor suficientemente bueno.
from sklearn.metrics import confusion_matrix, classification_report
print("Matriz de confusión\n\n", confusion_matrix(y_test_clf, y_pred_clf), "\n")
print(classification_report(y_test_clf, y_pred_clf))
Matriz de confusión
[[126 50 77 267 7]
[102 56 49 327 9]
[ 95 43 121 156 2]
[ 90 60 45 445 12]
[ 35 33 16 283 22]]
precision recall f1-score support
Mixed 0.28 0.24 0.26 527
Mostly Positive 0.23 0.10 0.14 543
Negative 0.39 0.29 0.33 417
Positive 0.30 0.68 0.42 652
Very Positive 0.42 0.06 0.10 389
accuracy 0.30 2528
macro avg 0.33 0.27 0.25 2528
weighted avg 0.32 0.30 0.26 2528
parametros para la regresión
pipeline_rg.get_params()
{'memory': None,
'steps': [('Preprocessing',
ColumnTransformer(transformers=[('MinMax', MinMaxScaler(),
['required_age', 'achievements',
'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])])),
('clf', Ridge())],
'verbose': False,
'Preprocessing': ColumnTransformer(transformers=[('MinMax', MinMaxScaler(),
['required_age', 'achievements',
'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])]),
'clf': Ridge(),
'Preprocessing__n_jobs': None,
'Preprocessing__remainder': 'drop',
'Preprocessing__sparse_threshold': 0.3,
'Preprocessing__transformer_weights': None,
'Preprocessing__transformers': [('MinMax',
MinMaxScaler(),
['required_age', 'achievements', 'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore', sparse=False),
['english',
'developer',
'publisher',
'platforms',
'categories',
'genres',
'tags'])],
'Preprocessing__verbose': False,
'Preprocessing__MinMax': MinMaxScaler(),
'Preprocessing__OneHot': OneHotEncoder(handle_unknown='ignore', sparse=False),
'Preprocessing__MinMax__clip': False,
'Preprocessing__MinMax__copy': True,
'Preprocessing__MinMax__feature_range': (0, 1),
'Preprocessing__OneHot__categories': 'auto',
'Preprocessing__OneHot__drop': None,
'Preprocessing__OneHot__dtype': numpy.float64,
'Preprocessing__OneHot__handle_unknown': 'ignore',
'Preprocessing__OneHot__sparse': False,
'clf__alpha': 1.0,
'clf__copy_X': True,
'clf__fit_intercept': True,
'clf__max_iter': None,
'clf__normalize': False,
'clf__random_state': None,
'clf__solver': 'auto',
'clf__tol': 0.001}
pipeline_rg.get_params()
{'memory': None,
'steps': [('Preprocessing',
ColumnTransformer(transformers=[('MinMax', MinMaxScaler(),
['required_age', 'achievements',
'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])])),
('Selection', SelectPercentile(percentile=90)),
('clf', SVR())],
'verbose': False,
'Preprocessing': ColumnTransformer(transformers=[('MinMax', MinMaxScaler(),
['required_age', 'achievements',
'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore',
sparse=False),
['english', 'developer', 'publisher',
'platforms', 'categories', 'genres',
'tags'])]),
'Selection': SelectPercentile(percentile=90),
'clf': SVR(),
'Preprocessing__n_jobs': None,
'Preprocessing__remainder': 'drop',
'Preprocessing__sparse_threshold': 0.3,
'Preprocessing__transformer_weights': None,
'Preprocessing__transformers': [('MinMax',
MinMaxScaler(),
['required_age', 'achievements', 'average_playtime', 'price']),
('OneHot',
OneHotEncoder(handle_unknown='ignore', sparse=False),
['english',
'developer',
'publisher',
'platforms',
'categories',
'genres',
'tags'])],
'Preprocessing__verbose': False,
'Preprocessing__MinMax': MinMaxScaler(),
'Preprocessing__OneHot': OneHotEncoder(handle_unknown='ignore', sparse=False),
'Preprocessing__MinMax__clip': False,
'Preprocessing__MinMax__copy': True,
'Preprocessing__MinMax__feature_range': (0, 1),
'Preprocessing__OneHot__categories': 'auto',
'Preprocessing__OneHot__drop': None,
'Preprocessing__OneHot__dtype': numpy.float64,
'Preprocessing__OneHot__handle_unknown': 'ignore',
'Preprocessing__OneHot__sparse': False,
'Selection__percentile': 90,
'Selection__score_func': <function sklearn.feature_selection._univariate_selection.f_classif(X, y)>,
'clf__C': 1.0,
'clf__cache_size': 200,
'clf__coef0': 0.0,
'clf__degree': 3,
'clf__epsilon': 0.1,
'clf__gamma': 'scale',
'clf__kernel': 'rbf',
'clf__max_iter': -1,
'clf__shrinking': True,
'clf__tol': 0.001,
'clf__verbose': False}
Se utilizan los regresores Ridge y SVM. En esta parte no se usan n-gramas.
params_rg = [
{'clf': [linear_model.Ridge()],
'clf__alpha' : [1,0.1,0.01,0.001,0.0001,0],
'clf__fit_intercept' : [True, False],
'clf__solver': ['svd', 'cholesky', 'sag', 'saga'],
},
{'clf': [svm.SVR()],
'clf__C' : [1, 10, 100, 1000],
'clf__kernel' : ['rbf'],
'clf__gamma' : [1e-3, 1e-4],
'Selection__percentile': [20, 40, 60, 80],
},
]
grid_rg=HalvingGridSearchCV(pipeline_rg,params_rg,verbose=10,n_jobs=-1,min_resources=2)
grid_rg.fit(X_train_rg, y_train_rg)
y_pred_rg = grid_rg.predict(X_test_rg)
n_iterations: 4 n_required_iterations: 4 n_possible_iterations: 8 min_resources_: 2 max_resources_: 5131 aggressive_elimination: False factor: 3 ---------- iter: 0 n_candidates: 80 n_resources: 2 Fitting 5 folds for each of 80 candidates, totalling 400 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan] warnings.warn( C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan] warnings.warn(
---------- iter: 1 n_candidates: 27 n_resources: 6 Fitting 5 folds for each of 27 candidates, totalling 135 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.89831977 0.94024355 0.94078713 0.94078991
0.99897063 0.9999337 0.9999742 0.99998337 1. 1.
0.99999376 0.99998552 1. 1. 0.9999562 0.99999856
0.99999983 0.99999983 0.99999321 0.99999914 0.99999989 0.99999989
0.99989507 0.99998342 0.99998337 -0.12902948 -0.12991206]
warnings.warn(
---------- iter: 2 n_candidates: 9 n_resources: 18 Fitting 5 folds for each of 9 candidates, totalling 45 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan -3.50654929e+03
-3.59584720e+03 -3.61805246e+03 -3.41608618e+03 -2.35395906e+03
-2.35383785e+03 -2.34985376e+03 -3.63502337e+03 -6.86780860e-01]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.89831977 0.94024355 0.94078713 0.94078991
0.99897063 0.9999337 0.9999742 0.99998337 1. 1.
0.99999376 0.99998552 1. 1. 0.9999562 0.99999856
0.99999983 0.99999983 0.99999321 0.99999914 0.99999989 0.99999989
0.99989507 0.99998342 0.99998337 -0.12902948 -0.12991206 0.9999859
0.99996644 0.99998331 0.99876468 0.93711918 0.93722795 0.93666696
1. -0.12789003]
warnings.warn(
---------- iter: 3 n_candidates: 3 n_resources: 54 Fitting 5 folds for each of 3 candidates, totalling 15 fits
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the test scores are non-finite: [ nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan nan
nan nan nan -3.50654929e+03
-3.59584720e+03 -3.61805246e+03 -3.41608618e+03 -2.35395906e+03
-2.35383785e+03 -2.34985376e+03 -3.63502337e+03 -6.86780860e-01
nan nan nan]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\model_selection\_search.py:918: UserWarning: One or more of the train scores are non-finite: [ nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan nan nan nan nan
nan nan 0.89831977 0.94024355 0.94078713 0.94078991
0.99897063 0.9999337 0.9999742 0.99998337 1. 1.
0.99999376 0.99998552 1. 1. 0.9999562 0.99999856
0.99999983 0.99999983 0.99999321 0.99999914 0.99999989 0.99999989
0.99989507 0.99998342 0.99998337 -0.12902948 -0.12991206 0.9999859
0.99996644 0.99998331 0.99876468 0.93711918 0.93722795 0.93666696
1. -0.12789003 nan nan nan]
warnings.warn(
C:\Users\admin\anaconda3\lib\site-packages\sklearn\feature_selection\_univariate_selection.py:116: RuntimeWarning: divide by zero encountered in true_divide
f = msb / msw
y_pred_rg
array([-76780.20154288, 48169.70383799, 844081.46798684, ...,
136945.44081388, -79898.99974787, 244878.08273667])
grid_rg.best_params_
{'clf': Ridge(alpha=1, solver='sag'),
'clf__alpha': 1,
'clf__fit_intercept': True,
'clf__solver': 'sag'}
print(f'El coeficiente R^2 es: {grid_rg.score(X_test_rg,y_test_rg)}')
El coeficiente R^2 es: 0.2010172341461205
Pudimos ver que mejor modelo mejora los resultados obtenidos en el baseline para la clasificación, pero la mejora es insignificante para la regresión.
En general se cumplió el objetivo del proyecto ya que se aplicaron los aprendizajes del curso. Sin embargo, los resultados finales no son tan buenos en consideración al baseline. De todos modos, vemos como un aprendizaje lo obtenido ya que logramos aplicar técnicas de optimización de modelos respecto al baseline.
Consideramos que usar una competencia para resolver este problema sirvió de motivación para obtener mejores resultados más allá de solo aplicar el modelo, aún teniendo en cuenta que nuestros resultados no fueron los mejores y se tiene una limitación para subir resultados, con lo cual se tiene que pensar y enfocar los esfuerzos cada vez que se intenta mejorar el modelo.
Tambien se considera que falto un estudio mas profundo sobre cada estimador para decidir exactamente que parametros se deberian probar, dado que no todos significa una alza en el rendimiento.
Para subir los resultados obtenidos a la pagina de CodaLab utilice la función generateFiles entregada mas abajo. Esto es debido a que usted deberá generar archivos que respeten extrictamente el formato de CodaLab, de lo contario los resultados no se veran reflejados en la pagina de la competencia.
Para los resultados obtenidos en su modelo de clasificación y regresión, estos serán guardados en un archivo zip que contenga los archivos predicctions_clf.txt para la clasificación y predicctions_rgr.clf para la regresión. Los resultados, como se comento antes, deberan ser obtenidos en base al dataset test.pickle y en cada una de las lineas deberan presentar las predicciones realizadas.
Ejemplos de archivos:
[ ] predicctions_clf.txt
Mostly Positive
Mostly Positive
Negative
Positive
Negative
Positive
...
[ ] predicctions_rgr.txt
16103.58
16103.58
16041.89
9328.62
107976.03
194374.08
...
df_test = pd.read_pickle("test.pickle")
df_test=df_test.drop(columns=['name', 'release_date'])
df_test.columns
Index(['english', 'developer', 'publisher', 'platforms', 'required_age',
'categories', 'genres', 'tags', 'achievements', 'average_playtime',
'price', 'short_description'],
dtype='object')
X_test_rg.columns
Index(['english', 'developer', 'publisher', 'platforms', 'required_age',
'categories', 'genres', 'tags', 'achievements', 'average_playtime',
'price', 'short_description'],
dtype='object')
X_train_clf.columns
Index(['english', 'developer', 'publisher', 'platforms', 'required_age',
'categories', 'genres', 'tags', 'achievements', 'average_playtime',
'price', 'short_description'],
dtype='object')
from zipfile import ZipFile
import os
def generateFiles(predict_data, clf_pipe, rgr_pipe):
"""Genera los archivos a subir en CodaLab
Input
predict_data: Dataframe con los datos de entrada a predecir
clf_pipe: pipeline del clf
rgr_pipe: pipeline del rgr
Ouput
archivo de txt
"""
y_pred_clf = clf_pipe.predict(predict_data)
y_pred_rgr = rgr_pipe.predict(predict_data)
with open('./predictions_clf.txt', 'w') as f:
for item in y_pred_clf:
f.write("%s\n" % item)
with open('./predictions_rgr.txt', 'w') as f:
for item in y_pred_rgr:
f.write("%s\n" % item)
with ZipFile('predictions.zip', 'w') as zipObj2:
zipObj2.write('predictions_rgr.txt')
zipObj2.write('predictions_clf.txt')
os.remove("predictions_rgr.txt")
os.remove("predictions_clf.txt")
generateFiles(df_test,grid,grid_rg)